package com.huiyeji.hui.context;

import com.huiyeji.hui.ws.ChatEndpoint;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author zhaoduo
 * 应用上下文对象
 */
public class HuiApplicationContext {

    protected static final HuiApplicationContext CONTEXT = new HuiApplicationContext();

    private final ConcurrentHashMap<Long, ChatEndpoint> onlineUsers;

    private final AtomicInteger onlineUserCount;

    private HuiApplicationContext(){
        this.onlineUsers = new ConcurrentHashMap<>();
        this.onlineUserCount = new AtomicInteger(0);
    }

    public ConcurrentHashMap<Long, ChatEndpoint> getOnlineUsers() {
        return onlineUsers;
    }

    public AtomicInteger getOnlineUserCount() {
        return onlineUserCount;
    }
}
